const app = getApp()
// pages/consult/consultSelect/consultSelect.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    url:'',
    array:['河南省 郑州市 中原区'],
    index: ['河南省 郑州市 中原区'],
    // array1:["国家一级咨询师","国家二级咨询师",'国家三级咨询师'],
    array1:[],
    index1:0,
    address:'',
    teacherLevel:'',

      list: [{
      name: "男",
      checked: true,
      },{
      name: "女",
      checked: false,
      },{
      name: "不限",
      checked: false,
      }],
      list1: [{
        name: "全部方式",
        checked: true,
        },{
        name: "视频咨询",
        checked: false,
        },{
        name: "语音咨询",
        checked: false,
        }],


    riderCommentList: [{
      value: '模糊数据',
      selected: false,
      title: '模糊数据'
     }, {
      value: '个人成长',
      selected: false,
       title: '个人成长'
     }, {
      value: '恋爱关系',
      selected: false,
       title: '恋爱关系'
     }, {
      value: '婚姻家庭',
      selected: false,
       title: '婚姻家庭'
     }, {
      value: '亲子教育',
      selected: false,
       title: '亲子教育'
     }, {
      value: '职场心理',
      selected: false,
       title: '职场心理'
     }, {
      value: '两性心理',
      selected: false,
      title: '两性心理'
     }, {
      value: '抑郁梳理',
      selected: false,
      title: '抑郁梳理'
     }, {
      value: '情绪管理',
      selected: false,
      title: '情绪管理'
     }, {
      value: '人际关系',
      selected: false,
      title: '人际关系'
     }, {
      value: '心理健康',
      selected: false,
      title: '心理健康'
     }, {
      value: '婆媳矛盾',
      selected: false,
      title: '婆媳矛盾'
     }]
  },

  bindPickerChange: function (e) {
    console.log('picker下拉项发生变化后，下标为：', e.detail.value)
    
    this.setData({
      index: e.detail.value,
      address:e.detail.value[0]+e.detail.value[1]+e.detail.value[2]
    })
    console.log(this.data.address)
  },
  bindPickerChange1: function (e) {
    let that = this
    console.log('picker下拉项发生变化后，下标为：', e.detail.value)
    that.setData({
      index1: e.detail.value,
      teacherLevel:that.data.array1[that.data.index1]
    })
    console.log(that.data.teacherLevel)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that = this
    that.setData({
      url:app.globalData.URL
    })
    wx.request({
      url: that.data.url+'teacherlevel/select',
      success(res) {
        console.log(res)
        for(let i=0;i<res.data.list.length;i++){
          that.data.array1[i] = res.data.list[i].name
        }
        that.setData({
          array1:that.data.array1
        })
        console.log(that.data.array1)
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  checkboxChange(e) {
    console.log('checkboxChange e:', e);
    let string = "riderCommentList[" + e.target.dataset.index + "].selected"
    this.setData({
     [string]: !this.data.riderCommentList[e.target.dataset.index].selected
    })
    let detailValue = this.data.riderCommentList.filter(it => it.selected).map(it => it.value)
    console.log('所有选中的值为：', detailValue)
   },
      toPage1(){
        wx.redirectTo({
          url: "/pages/consult/consultShaiXuanjieguo/consultShaiXuanjieguo",
        })
      }

})